package 多线程;

import java.util.concurrent.TimeUnit;

public class Resource {
    public synchronized void h(){
        for (int i = 0; i <5 ; i++) {
            System.out.println(Thread.currentThread().getName()+"h() is running");
            try{
                TimeUnit.SECONDS.sleep(2);
            }catch(InterruptedException e ){
                e.printStackTrace();
            }
            
        }
    }

    public static void main(String[] args) {
        Resource resource = new Resource();
        new Thread(()->resource.h()).start();
        new Thread(()->resource.h()).start();
        resource.h();

    }
}
